<?php

class Pointrecord extends \Eloquent {
	protected $fillable = [];

    public function user(){
        return $this->belongsTo('User');
    }

    /**
     * @param $count 分数
     * @param $action 操作
     * @param $add 1：加 0：减
     * @param $action_id   相关操作id
     * @param $customer_id 增加积分的用户id
     * @param null $user_id 被邀请人id
     */
    public static function new_record($count,$action,$add,$action_id,$customer_id,$user_id = null){
        $record = new Pointrecord();
        $record->add = $add;
        $record->count = $count;
        $record->action = $action;
        $record->action_id = $action_id;
        $record->customer_id = $customer_id;
        $record->user_id = $user_id;
        $record->save();
    }

    public function inviteid(){
        return $this->hasOne('Customer','id','user_id');
    }
}